package java68_3;

import java.util.Scanner;
public class LuckyPrize {
    public static void main(String[] args) {
        char a='y';
        boolean e=false;
        String b="";
        int c=0;
        do {
            System.out.println("**********欢迎进入奖客富翁系统**********");
            System.out.println("           1.注册");
            System.out.println("           2.登录");
            System.out.println("           3.抽奖");
            System.out.println("************************************");
            Scanner input = new Scanner(System.in);
            System.out.println("请选择菜单：");
            int i = input.nextInt();
            if (i == 1) {
                System.out.println("注册");
                System.out.println("请填写个人信息：");
                System.out.println("用户名：");
                 b = input.next();
                System.out.println("密码：");
                 c = input.nextInt();
                int d = (int) (Math.random() * 9000) + 1000;
                System.out.println("注册成功，请记住你的会员卡号");
                System.out.println("用户名\t密码\t会员卡号");
                System.out.println(b + "\t" + c + "\t" + d);
            }
           else if (i == 2) {
                System.out.println("登录");
                int j = 1;
                System.out.println("请输入用户名：");
                String m = input.next();
                System.out.println("请输入密码：");
                int n = input.nextInt();
                while (j <= 3) {
                    if (m.equals(b) && n == c) {
                        System.out.println("登录成功");
                        e = true;
                        break;
                    } else {
                        System.out.println("输入错误，请重新输入：");
                        m = input.next();
                        n = input.nextInt();
                        j++;
                        //continue;
                    }
                }
               // continue;
            }
            else if (i == 3 && e) {
                System.out.println("抽奖");
                int[] arr = new int[5];
                for (int o = 0; o < arr.length; o++) {
                    arr[o] = (int) (Math.random() * 9000) + 1000;
                }
                System.out.print("本期的幸运数字为：");
                System.out.println();
                for (int x = 0; x < arr.length; x++) {
                    System.out.print(arr[x] + " ");
                }
                System.out.println("请输入你的卡号：");
                double cardNo = input.nextInt();
                for (int x1 = 0; x1 < arr.length; x1++) {
                    if (cardNo == arr[x1]) {
                        System.out.println("恭喜你！你是本期幸运用户！");
                        break;
                    } else if (x1 == arr.length - 1) {
                        System.out.println("抱歉，你不是本期幸运用户");
                        break;
                    }
                }
            } else{
                System.out.println("输入有误，请重新输入：");
                i = input.nextInt();
                continue;
            }
            System.out.println("继续吗？（y / n）:");
            a = input.next().charAt(0);
        }while(a=='y');
        System.out.println("系统退出，谢谢使用！");
    }
}
